//
//  UserFavorTableHandler.m
//  collection
//
//  Created by 靖 张 on 12/13/11.
//  Copyright (c) 2011 Tsinghua University. All rights reserved.
//

#import "UserFavorTableHandler.h"
#import "FeedCell.h"

@implementation UserFavorTableHandler

@synthesize homepageRootController = _homepageRootController;
@synthesize dataList = _dataList;

#pragma mark - Implementation of UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return [self.dataList count];
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString* latestInfoCellID = @"LatestInfoCell";
    FeedCell* cell = (FeedCell*)[tableView dequeueReusableCellWithIdentifier:latestInfoCellID];
    if (cell == nil) {
        cell = [[[FeedCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:latestInfoCellID] autorelease];
    }
    
    // Customise the cell
    Feed* feed = [self.dataList objectAtIndex:indexPath.row];
    [cell updateCell:feed delegate:nil];
    
    [cell.favouriteButton setBackgroundImage:[UIImage imageNamed:@"ico_heart_on"] forState:UIControlStateDisabled];
    cell.favouriteButton.enabled = NO;
    
    return cell;
}

#pragma mark - Implementation of UITableViewDelegate


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell* cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
    return cell.frame.size.height;
}


@end
